package com.app.view.component.common 
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	import org.component.Button;
	import com.peachcastle.core.Display;
	import com.peachcastle.interfaces.IScene;
	
	import com.app.model.data.UserData;
	import com.app.model.data.LevelData;

	import com.app.view.component.scene.HallScene;
	import com.app.view.component.scene.RoomScene;
	import com.app.view.manager.LayerManagerMediator;
	import com.app.view.manager.DialogManagerMediator;
	
	import com.peachcastle.tools.DToolTip;
	import com.peachcastle.tools.Assert;
	import com.peachcastle.debug.Log;
	
	import com.peachcastle.tools.DToolTip;
	
	/**
	 * ...
	 * @author kevin
	 */
	public class Toolbar extends Display
	{
		private var _mediator:Mediator = null;
		
		private var _layers:Array = null;
		private var _sence:IScene = null;

		private var _userInfo:UserInfo = null;

		private var _btnFeedback:Button = null;
		private var _btnSetting:Button = null;
		private var _btnFaq:Button = null;
		private var _btnMessage:Button = null;
		
		public function Toolbar(ui:MovieClip, mediator:Mediator) 
		{
			_mediator = mediator;
			
			super(ui);
		}
		
		override protected function initialization():void 
		{
			super.initialization();
			
			DToolTip.init(assest, true);

			_userInfo = new UserInfo(assest);
			
			_btnFeedback = new Button(assest['btn_feedback']);
			//_btnUserInfo.setDisable(true);
			
			_btnSetting = new Button(assest['btn_setting']);
			_btnSetting.setDisable(true);
			
			_btnFaq = new Button(assest['btn_faq']);
			_btnFaq.setDisable(true);
			
			_btnMessage = new Button(assest['btn_message']);
			_btnMessage.setDisable(true);
			
			DToolTip.register(_btnFeedback.assest, "回報", "bottom");
			DToolTip.register(_btnSetting.assest, "設置(尚未開放)", "bottom");
			DToolTip.register(_btnFaq.assest, "FAQ(尚未開放)", "bottom");
			DToolTip.register(_btnMessage.assest, "消息中心(尚未開放)", "bottom");
		}
		
		override protected function configEventListeners():void 
		{
			super.configEventListeners();

			_btnFeedback.addEventListener(MouseEvent.CLICK, showFeedbackView);
		}
		
		private function showFeedbackView(e:MouseEvent):void
		{
			var layer:DisplayObject = null;
			switch(_sence.name)
			{
				case HallScene.NAME:
					layer = _layers[LayerManagerMediator.HALL_LAYER];
					
					break;
						
				case RoomScene.NAME:
					layer = _layers[LayerManagerMediator.ROOM_LAYER];
					
					break;	
			}
			
			if(layer) _mediator.sendNotification(DialogManagerMediator.SHOW_DIALOG, ['feedBackView', {'layer': layer}]);
		}
		
		public function update(data:UserData = null, isNewLevel:Boolean = false, userLevel:LevelData = null, useAnimationInExp:Boolean = false):void
		{
			_userInfo.update(data, isNewLevel, userLevel, useAnimationInExp);
		}
		
		public function set layers(layers:Array):void { _layers = layers; }
		public function set sence(sence:IScene):void { _sence = sence; }
	}

}